﻿@model IEnumerable<ElCharro01.Models.Order>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<div class="grid_10 alpha paddalo">
 @using (Html.BeginForm("Index", "Order", FormMethod.Get))
        {
            @Html.DropDownList("orderedBy", new SelectList(ViewBag.OrdPossibility), new { onchange = "this.form.submit();" })
        }
<h2 align="center">Ordini Da Evadere</h2>

    @if (Model.Count() == 0)
    {
        <div>Non Ci Sono Ordini In Lavorazione</div> 
    }
    else
    {
        <table class="grid_9">
            <tr>
                <th>
                    Username Utente
                </th>
                <th>
                    Nome Utente
                </th>
                <th>
                    Cognome Utente
                </th>
                <th>
                    DataOrdine
                </th>
                <th>
                    Totale (€)
                </th>
                <th>
                    TipoDiPagamento
                </th>
                <th>
                    Pagamento Confermato
                </th>
                 <th>
                    Spedizione Confermata
                </th>
                <th></th>
            </tr>
        
        @foreach (var item in Model)
        {
           
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Customer.Username)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Customer.Nome)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Customer.Cognome)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DataOrdine)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Totale)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TipoDiPagamento)
                </td>
               @using (Html.BeginForm("PaymentConfirmed", "Order", new { OrderID = item.Id }))
               {
                <td>
                    @Html.CheckBox("confirmed", item.ConfermaPagamento, new { onchange = "this.form.submit();" })
                </td>
               }
                  @using (Html.BeginForm("ShipmentCodeInsert", "Order", new { OrderID = item.Id }))
                  {
                <td>
                    @Html.CheckBox("confirmed", item.ConfermaSpedizione, new { onchange = "this.form.submit();" })
                </td>
                   }
             
                <td>
                @Html.ActionLink("Elimina", "Delete", "Order", new { id = item.Id, area = "Admin" }, new { })         
                    
                </td>
                
            </tr>
            
        }
        
        </table>
    }
    </div>